package J11_9.J11_8.operation;

import J11_9.J11_8.book.BookList;

import java.util.Scanner;

public class BackBook implements IOperation {


    @Override
    public void work(BookList bookList) {
        System.out.println("归还图书");

        Scanner in = new Scanner(System.in);
        System.out.println("请输入书名");
        String name = in.nextLine();
        for (int i = 0; i < bookList.getBookCount(); i++) {
            if(bookList.getBooks(i).getName().equals(name)){
                if(bookList.getBooks(i).isaBoolean()){
                    System.out.println("归还成功");
                    bookList.getBooks(i).setaBoolean(false);
                    return;
                }else{
                    System.out.println("该书未被借阅");
                    return;
                }
            }

        }
    }
}
